
type UserExperiencePostReq struct {
	g.Meta   `path:"/User/Experience" method:"post" tags:"UserService" summary:"添加用户技能"`
	Media  string      `v:"required"`
	Expiry string      `v:"required"`
}
type UserExperienceReq struct {
	g.Meta   `path:"/User/Experience" method:"get" tags:"UserService" summary:"检索认证用户的技能"`
	Experience_id uint      `v:"required"`
}
type UserExperienceUpReq struct {
	g.Meta   `path:"/User/Experience" method:"patch" tags:"UserService" summary:"更新特定的简历"`
	Media  string      `v:"required"`
	Expiry string      `v:"required"`
}
type UserExperienceDeleReq struct {
	g.Meta   `path:"/User/Experience" method:"delete" tags:"UserService" summary:"删除特定的简历"`
	Experience_id uint      `v:"required"`
}


func (c *ControllerV1) UserExperience(ctx context.Context, req *v1.UserExperienceReq) (res *v1.UserExperienceRes, err error) {
	var account *entity.Account
	account = service.Session().GetUser(ctx)
	fmt.Println(account)
	if account == nil {
		return nil, gerror.New(`Please login first`)
	}
	var user *entity.Experience
	err = g.Model("Experience").Where("id", req.Experience_id).Scan(&user)
	fmt.Println(err)
	res = &v1.UserExperienceRes{
		user,
	}
	return
}

func (c *ControllerV1) UserExperienceUp(ctx context.Context, req *v1.UserExperienceUpReq) (res *v1.UserExperienceUpRes, err error) {
	var account *entity.Account
	account = service.Session().GetUser(ctx)
	fmt.Println(account)
	if account == nil {
		return nil, gerror.New(`Please login first`)
	}
	id, err := g.Model("Experience").Data(g.Map{
		"user_id" : req.User_id,
		"start_date" : req.Start_date,
		"end_date" : req.End_date,
		"isPresent" : req.IsPresent,
		"description" : req.Description,
		"title" : req.Title,
		"company" : req.Company,
		"company_string" : req.Company_string,
	}).Where("id", req.Experience_id).Update()
	fmt.Println(id)
	return
}

func (c *ControllerV1) UserExperiencePost(ctx context.Context, req *v1.UserExperiencePostReq) (res *v1.UserExperienceUpRes, err error) {
	var account *entity.Account
	account = service.Session().GetUser(ctx)
	fmt.Println(account)
	if account == nil {
		return nil, gerror.New(`Please login first`)
	}
	id, err := g.Model("Experience").Data(g.Map{
		"user_id" : req.User_id,
		"start_date" : req.Start_date,
		"end_date" : req.End_date,
		"isPresent" : req.IsPresent,
		"description" : req.Description,
		"title" : req.Title,
		"company" : req.Company,
		"company_string" : req.Company_string,
	}).Insert()
	fmt.Println(id)
	return
}

func (c *ControllerV1) UserExperienceDele(ctx context.Context, req *v1.UserExperienceDeleReq) (res *v1.UserExperienceUpRes, err error) {
	var account *entity.Account
	account = service.Session().GetUser(ctx)
	fmt.Println(account)
	if account == nil {
		return nil, gerror.New(`Please login first`)
	}
	id, err := g.Model("Experience").Where("id", req.Experience_id).Delete()
	fmt.Println(id)
	return
}